﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Media.Media3D;


namespace PlanetsAndOrbs
{
    class ReflectiveSphere : Sphere
    {
        Vector3D filter_, emission_;

        public ReflectiveSphere(Vector3D center, float radius, Color filter, Color emission)
            : base(center, radius)
        {
            filter_ = PixelRenderer.color2V3D(filter);
            emission_ = PixelRenderer.color2V3D(emission);
            normalizeColors(ref filter_, ref emission_);
        }

        public override bool trace(ref Vector3D origin, ref Vector3D ray, out Vector3D filter, out Vector3D emission)
        {
            // calculate the normal vector
            Vector3D normal = origin - center_;
            normal.Normalize();
            
            double alpha = reflect(ref ray, normal);
            emission = emission_ * alpha;
            filter = filter_ * (1 - alpha);
            return false;
        }
    }
}
